<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\cdc\report;

use app\service\BaseService;

abstract class ReportService extends BaseService
{
    /**
     * 获取列表.
     * @param array $where 条件
     * @return mixed
     */
    public static function getList(array $where = [])
    {
        return static::getModel()->where($where)->limit(200)->field(true)->select();
    }

    /**
     * 修改状态
     * @return mixed
     */
    public static function updateSync(string $id = '')
    {
        return static::getModel()->where('_id', $id)->update(['is_sync' => static::getModel()::SYNC_SUCCESS]);
    }

    /**
     * 修改数据.
     * @return mixed
     */
    public static function updateData(array $where = [], array $data = [])
    {
        $data['update_time'] = time();
        return static::getModel()->where($where)->update($data);
    }

    /**
     * 删除数据.
     * @return mixed
     */
    public static function deleteData(array $where = [])
    {
        return static::getModel()->where($where)->delete();
    }

    /**
     * 查找信息.
     * @param array $where 条件
     * @return mixed
     */
    public static function getInfo(array $where = [])
    {
        return static::getModel()->where($where)->field(true)->find();
    }
}
